{% extends "shared/layout.volt" %}
{% block content %}
    <h1 class="page-header">支付配置</h1>
    <div class="payment-form-box">
    <ul class="payment-select-step">
        <li>
            <i class="fa fa-list-alt icon" aria-hidden="true"></i>
            <h6>STEP.1</h6>
            <h2>选择支付类型、支付接口类型和密钥类型</h2>
            <i class="fa fa-chevron-right arrow" aria-hidden="true"></i>
        </li>
        <li class="current">
            <i class="fa fa-edit icon" aria-hidden="true"></i>
            <h6>STEP.2</h6>
            <h2>配置支付账号、证书和密钥</h2>
        </li>
    </ul>

    <div class="form-box" style="width: 850px;margin-top: 20px;">
    <form class="form-horizontal" method="post" id="payAddForm">
        <input type="hidden" name="pay_id" value="{{ payment_config_id }}">
        <input type="hidden" name="pay_platform" value="{{ payment_platform }}">
        <input type="hidden" name="gateway" value="{{ payment_gateway }}">
        <input type="hidden" name="sign_type" value="{{ encryption }}">
        <input type="hidden" name="mch_id" value="{{ merchant_id }}">
        <div class="form-group">
            <label class="col-sm-3 control-label">支付类型</label>
            <div class="col-sm-9">
                <p class="form-control-static">{{ payment_type }} <a href="{{ url('home/edit') }}" class="btn btn-primary btn-xs" >编辑</a></p>
            </div>
        </div>
        <div class="form-group">
            <label for="app_id" class="col-sm-3 control-label">支付名称</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" id="pay_name" name="pay_name" placeholder="支付名称">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">启用状态</label>
            <div class="col-sm-9">
                <div class="radio_box">
                    <label for="payment_state1" class="enable selected">启用</label>
                    <label for="payment_state2" class="disable ">禁用</label>
                    <input type="radio" checked="checked" value="y" name="pay_status" id="payment_state1">
                    <input type="radio" value="n" name="pay_status" id="payment_state2">
                </div>
            </div>
        </div>
        {% if payment_platform == 'wxpay' or payment_platform == 'wxpay_global' %}
        <div class="form-group">
            <label for="app_id" class="col-sm-3 control-label">商户公众号APPID</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" id="app_id" name="pay_config[app_id]" placeholder="商户公众号APPID">
            </div>
        </div>
            <div class="form-group">
                <label for="mch_id" class="col-sm-3 control-label">商户号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="mch_id" name="pay_config[mch_id]" placeholder="商户号">
                </div>
            </div>

            <div class="form-group">
                <label for="encryption" class="col-sm-3 control-label">{{ encryption_name }}</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="encryption_key" name="pay_config[encryption_key]" placeholder="{{ encryption_name }}">
                </div>
            </div>
            <div class="form-group">
                <label for="encryption" class="col-sm-3 control-label">公众号密钥</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="encryption_key" name="pay_config[secert]" placeholder="公众号密钥">
                    <div class="sub-text">公众帐号:仅JSAPI支付的时候需要配置， 登录公众平台，进入开发者中心可设置</div>
                </div>
            </div>
            <div class="form-group">
                <label for="rootca" class="col-sm-3 control-label">CA证书</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="rootca" name="pay_config[rootca]" placeholder="CA证书" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">证书下载方法：微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->证书下载。</div>
                </div>
            </div>
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">商户证书</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="merchant_cert" name="pay_config[merchant_cert]" placeholder="商户证书" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">证书下载方法：微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->证书下载。</div>
                </div>
            </div>
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">商户证书密钥</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="merchant_cert_key" name="pay_config[merchant_cert_key]" placeholder="商户证书密钥" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">证书下载方法：微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->证书下载。</div>
                </div>
            </div>
        {% endif %}
        <!---国内支付宝--->
    {% if payment_platform == 'alipay' %}
        {% if payment_gateway == 'wireless' or payment_gateway == 'partner' %}
            <div class="form-group">
                <label for="alipay_account" class="col-sm-3 control-label">支付宝账号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="alipay_account" name="pay_config[alipay_account]" placeholder="支付宝账号">
                </div>
            </div>
            <div class="form-group">
                <label for="app_id" class="col-sm-3 control-label">合作伙伴身份（PID）</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="partner" name="pay_config[partner]" placeholder="合作伙伴身份（PID）">
                </div>
            </div>
        {% if encryption == 'MD5' %}
            <div class="form-group">
                <label for="encryption" class="col-sm-3 control-label">{{ encryption_name }}</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="encryption_key" name="pay_config[encryption_key]" placeholder="{{ encryption_name }}">
                </div>
            </div>
        {% endif %}
        {% if encryption == 'SHA1WithRSA' %}
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">证书生成方法：<a href="https://docs.open.alipay.com/291/106130" target="_blank">使用 OpenSSL 生成RSA证书</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=wireless" target="_blank">蚂蚁金服秘钥管理后台</a>配置秘钥。</div>
                </div>
            </div>
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="支付宝公钥" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=partner" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。</div>
                </div>
            </div>
        {% endif %}
        {% if encryption == 'DSA' %}
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">证书生成方法：<a href="https://tech.open.alipay.com/support/knowledge/index.htm?knowledgeId=201602078539&categoryId=20069#/?_k=cq8m27" target="_blank">DSA私钥及公钥生成</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=wireless" target="_blank">蚂蚁金服密钥管理后台</a>配置秘钥。</div>
                </div>
            </div>
            <div class="form-group">
                <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                <div class="col-sm-9">
                    <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="支付宝公钥" style="height: 320px;resize: none;"></textarea>
                    <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=partner" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。</div>
                </div>
            </div>
        {% endif %}
        {% endif %}
        {% if payment_gateway == 'openapp' %}
            <!--蚂蚁金服开放平台接口-->
            <div class="form-group">
                <label for="alipay_account" class="col-sm-3 control-label">支付宝账号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="alipay_account" name="pay_config[alipay_account]" placeholder="支付宝账号">
                </div>
            </div>
            <div class="form-group">
                <label for="app_id" class="col-sm-3 control-label">应用ID（APPID）</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="app_id" name="pay_config[app_id]" placeholder="应用ID（APPID）">
                </div>
            </div>
            {% if encryption == 'SHA1WithRSA' %}
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">证书生成方法：<a href="https://docs.open.alipay.com/291/106130" target="_blank">使用 OpenSSL 生成RSA证书</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服秘钥管理后台</a>配置秘钥。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="查看支付宝公钥" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。</div>
                    </div>
                </div>

            {% endif %}
            {% if encryption == 'SHA256WithRSA' %}
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">证书生成方法：<a href="https://docs.open.alipay.com/291/106130" target="_blank">使用 OpenSSL 生成RSA证书</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服秘钥管理后台</a>配置秘钥。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="查看支付宝公钥" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。 </div>
                    </div>
                </div>

            {% endif %}
            {% if encryption == 'AES' %}
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                    <div class="col-sm-9">
                        <input class="form-control" id="alipay_aes_key" name="pay_config[alipay_aes_key]" placeholder="{{ encryption_name }}" >
                        <div class="sub-text">需要在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=wireless" target="_blank">蚂蚁金服密钥管理后台</a>配置密钥。</div>
                    </div>
                </div>
            {% endif %}
        {% endif %}
    {% endif %}
        <!--微信配置-->
        {% if payment_platform == 'alipay_global' %}
            <div class="form-group">
                <label for="alipay_account" class="col-sm-3 control-label">支付宝账号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="alipay_account" name="pay_config[alipay_account]" placeholder="支付宝账号">
                </div>
            </div>
            <div class="form-group">
                <label for="app_id" class="col-sm-3 control-label">合作伙伴身份（PID）</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="partner" name="pay_config[partner]" placeholder="合作伙伴身份（PID）">
                </div>
            </div>
            {% if encryption == 'SHA1WithRSA' %}
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">证书生成方法：<a href="https://docs.open.alipay.com/291/106130" target="_blank">使用 OpenSSL 生成RSA证书</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服秘钥管理后台</a>配置秘钥。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="查看支付宝公钥" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。</div>
                    </div>
                </div>

            {% endif %}
            {% if encryption == 'DSA' %}
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">{{ encryption_name }}</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_private_cert" name="pay_config[alipay_private_cert]" placeholder="{{ encryption_name }}" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">证书生成方法：<a href="https://tech.open.alipay.com/support/knowledge/index.htm?knowledgeId=201602078539&categoryId=20069#/?_k=cq8m27" target="_blank">DSA私钥及公钥生成</a> ，生成证书后需要在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=wireless" target="_blank">蚂蚁金服密钥管理后台</a>配置秘钥。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="apiclient_cert" class="col-sm-3 control-label">支付宝公钥</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" id="alipay_public_cert" name="pay_config[alipay_public_cert]" placeholder="查看支付宝公钥" style="height: 320px;resize: none;"></textarea>
                        <div class="sub-text">支付宝公钥查看：在<a href="https://openhome.alipay.com/platform/keyManage.htm?keyType=partner" target="_blank">蚂蚁金服密钥管理中心</a> 配置私钥后，会生成对应公钥。</div>
                    </div>
                </div>
            {% endif %}
        {% endif %}
        <div class="form-group">
            <label for="app_id" class="col-sm-3 control-label">支付简介</label>
            <div class="col-sm-9">
                <textarea class="form-control" id="remark" name="remark" placeholder="支付简介" style="height: 120px;resize: none;"></textarea>

            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-8">
                <button type="submit" class="btn btn-success" data-loading-text="保存中...">保存</button>
                <button type="button" class="btn btn-default" onclick="window.location=window.document.referrer;">返回</button>
            </div>
        </div>
    </form>
    </div>
    </div>
{% endblock %}
{% block footer %}
<script type="text/javascript">
    $("#payAddForm").ajaxForm({
        type :"POST",
        dataType : "json",
        beforeSubmit : function () {
            $("#payAddForm").find("button[type='submit']").button('loading');
        } ,
        success : function ($res) {
            if($res.errCode === 0 || $res.errCode === '0'){
                layer.msg($res.errMsg,{time : 1000,icon :6},function () {
                    window.location = "{{ url("home/list") }}";
                });
            }else{
                layer.msg($res.errMsg,{time : 1500,icon :2});
            }
            $("#payAddForm").find("button[type='submit']").button('reset');
        },
        error : function () {
            $("#payAddForm").find("button[type='submit']").button('reset');
        }
    });
</script>
{% endblock %}